package com.bwie.sixth.commerce.controller;

import java.util.Arrays;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bwie.sixth.commerce.entity.RecordListEntity;
import com.bwie.sixth.commerce.service.RecordListService;
import com.bwie.common.utils.PageUtils;
import com.bwie.common.utils.R;



/**
 * 用户打开看到自己参与拼团活动的表
 *
 * @author lzl
 * @email 1601711944@gmail.com
 * @date 2021-09-10 15:07:15
 */
@RestController
@RequestMapping("commerce/recordlist")
public class RecordListController {
    @Autowired
    private RecordListService recordListService;

    /**
     * 列表
     */
    @RequestMapping("/list")

    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = recordListService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{recordId}")

    public R info(@PathVariable("recordId") Integer recordId){
		RecordListEntity recordList = recordListService.getById(recordId);

        return R.ok().put("recordList", recordList);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")

    public R save(@RequestBody RecordListEntity recordList){
		recordListService.save(recordList);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")

    public R update(@RequestBody RecordListEntity recordList){
		recordListService.updateById(recordList);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")

    public R delete(@RequestBody Integer[] recordIds){
		recordListService.removeByIds(Arrays.asList(recordIds));

        return R.ok();
    }

    @RequestMapping("add")
    public R add(@RequestBody RecordListEntity recordListEntity){
        String add = recordListService.add(recordListEntity);
        return R.ok().put("add",add);
    }

}
